package com.cal.utms.action.dealing;

import com.cal.utms.dto.dealing.InstrumentDto;
import com.cal.utms.model.dealing.InstrumentModel;
import com.cal.utms.model.dealing.PurchaseDealModel;
import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;

public class InstrumentAction extends ActionSupport implements ModelDriven<InstrumentDto> {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private InstrumentDto instrumentDto = new InstrumentDto();
	private int instrumentTypeId;
	private int instrumentId;

	public String getInstrumentByType() {
		PurchaseDealModel model = new PurchaseDealModel();
		instrumentDto.setInstrumentDtos(model.getInstrumentByType(instrumentTypeId));
		instrumentDto.setSuccess(true);
		return Action.SUCCESS;
	}

	public String getInstrumentById() {
		InstrumentModel instrumentModel = new InstrumentModel();
		instrumentDto.getInstrumentDtos().add(instrumentModel.getInstrumentById(instrumentId));
		instrumentDto.setSuccess(true);
		return Action.SUCCESS;
	}

	@Override
	public InstrumentDto getModel() {
		return instrumentDto;
	}

	public InstrumentDto getInstrumentDto() {
		return instrumentDto;
	}

	public void setInstrumentDto(InstrumentDto instrumentDto) {
		this.instrumentDto = instrumentDto;
	}

	public int getInstrumentTypeId() {
		return instrumentTypeId;
	}

	public void setInstrumentTypeId(int instrumentTypeId) {
		this.instrumentTypeId = instrumentTypeId;
	}

	public int getInstrumentId() {
		return instrumentId;
	}

	public void setInstrumentId(int instrumentId) {
		this.instrumentId = instrumentId;
	}
}
